import unittest
import sys

sys.path.append(u'E:\\Python\\APITest\\classonline_course_2018\\Day1')
from Day1.myList import MyList


class TestMySplice(unittest.TestCase):
    # 传入数字列表, 正常删除元素
    def test01(self):
        ml = MyList([1, 2, 3, 4, 5, 6])
        actual = ml.mySplice(2, 3)
        expect = [1, 2, 6]
        self.assertEqual(expect, actual)

    # 传入字符串列表,正常删除元素
    def test02(self):
        ml = MyList(['a', 'b', 'c', 'd'])
        actual = ml.mySplice(1, 2)
        expect = ['a', 'd']
        self.assertEqual(expect, actual)

    # 长度为1的列表
    def test03(self):
        ml = MyList([1])
        actual = ml.mySplice(0, 1)
        expect = []
        self.assertEqual(expect, actual)

    # 删除全部元素
    def test04(self):
        ml = MyList([1, 2, 'hello', 4, 5])
        actual = ml.mySplice(0, 5)
        expect = []
        self.assertEqual(expect, actual)

    # 嵌套列表删除元素
    def test05(self):
        ml = MyList([1, [2, 'hello'], 4, [5, 'world']])
        actual = ml.mySplice(0, 2)
        expect = [4, [5, 'world']]
        self.assertEqual(expect, actual)


if __name__ == '__main__':
    suite = unittest.TestSuite()
    testCase = unittest.TestLoader().loadTestsFromTestCase(TestMySplice)
    suite.addTest(testCase)
    r = unittest.TestResult()
    suite.run(result=r)
    print(r.__dict__)
